package com.springcloud;

import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;

/**
 * @ProjectName: springcloud_day1
 * @Package: com.springcloud
 * @ClassName: springcloud_8001
 * @Author:
 * @Description:
 * @Date: 2020/10/20 11:44
 * @Version: 1.0
 */
@SpringBootApplication
//@ComponentScan(basePackages = {"com.com.springcloud"})
@EnableEurekaClient  //服务启动后自动注册到eureka中
@EnableDiscoveryClient  //服务发现
public class springcloud_8001 {
    public static void main(String[] args) {
        SpringApplication.run(springcloud_8001.class, args);
    }


    /**
     *  此处是流监控时才用到的 ，固定写法
     * @return
     */
    @Bean
    public ServletRegistrationBean hystrixMetricsStreamServlet() {
        ServletRegistrationBean registrationBean = new ServletRegistrationBean(new HystrixMetricsStreamServlet());
        registrationBean.addUrlMappings("/actuator/hystrix.stream");
        return registrationBean;
    }
}
